/*
 * XML Type:  SegmentCollection
 * Namespace: http://www.data-archive.ac.uk/dext/schema/draft
 * Java type: uk.da.dext.SegmentCollection
 *
 * Automatically generated - do not modify.
 */
package uk.da.dext.impl;

import uk.da.dext.SegmentType;

/**
 * An XML SegmentCollection(@http://www.data-archive.ac.uk/dext/schema/draft).
 *
 * This is a complex type.
 */
public class SegmentCollectionImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements uk.da.dext.SegmentCollection
{
    private static final long serialVersionUID = 1L;
    
    public SegmentCollectionImpl(org.apache.xmlbeans.SchemaType sType)
    {
        super(sType);
    }
    
    private static final javax.xml.namespace.QName SEGMENT$0 = 
        new javax.xml.namespace.QName("http://www.data-archive.ac.uk/dext/schema/draft", "segment");
    private static final javax.xml.namespace.QName ID$2 = 
        new javax.xml.namespace.QName("", "id");
    
    
    /**
     * Gets array of all "segment" elements
     */
    public uk.da.dext.SegmentType[] getSegmentArray()
    {
        synchronized (monitor())
        {
            check_orphaned();
            java.util.List<SegmentType> targetList = new java.util.ArrayList<SegmentType>();
            get_store().find_all_element_users(SEGMENT$0, targetList);
            uk.da.dext.SegmentType[] result = new uk.da.dext.SegmentType[targetList.size()];
            targetList.toArray(result);
            return result;
        }
    }
    
    /**
     * Gets ith "segment" element
     */
    public uk.da.dext.SegmentType getSegmentArray(int i)
    {
        synchronized (monitor())
        {
            check_orphaned();
            uk.da.dext.SegmentType target = null;
            target = (uk.da.dext.SegmentType)get_store().find_element_user(SEGMENT$0, i);
            if (target == null)
            {
                throw new IndexOutOfBoundsException();
            }
            return target;
        }
    }
    
    /**
     * Returns number of "segment" element
     */
    public int sizeOfSegmentArray()
    {
        synchronized (monitor())
        {
            check_orphaned();
            return get_store().count_elements(SEGMENT$0);
        }
    }
    
    /**
     * Sets array of all "segment" element
     */
    public void setSegmentArray(uk.da.dext.SegmentType[] segmentArray)
    {
        synchronized (monitor())
        {
            check_orphaned();
            arraySetterHelper(segmentArray, SEGMENT$0);
        }
    }
    
    /**
     * Sets ith "segment" element
     */
    public void setSegmentArray(int i, uk.da.dext.SegmentType segment)
    {
        synchronized (monitor())
        {
            check_orphaned();
            uk.da.dext.SegmentType target = null;
            target = (uk.da.dext.SegmentType)get_store().find_element_user(SEGMENT$0, i);
            if (target == null)
            {
                throw new IndexOutOfBoundsException();
            }
            target.set(segment);
        }
    }
    
    /**
     * Inserts and returns a new empty value (as xml) as the ith "segment" element
     */
    public uk.da.dext.SegmentType insertNewSegment(int i)
    {
        synchronized (monitor())
        {
            check_orphaned();
            uk.da.dext.SegmentType target = null;
            target = (uk.da.dext.SegmentType)get_store().insert_element_user(SEGMENT$0, i);
            return target;
        }
    }
    
    /**
     * Appends and returns a new empty value (as xml) as the last "segment" element
     */
    public uk.da.dext.SegmentType addNewSegment()
    {
        synchronized (monitor())
        {
            check_orphaned();
            uk.da.dext.SegmentType target = null;
            target = (uk.da.dext.SegmentType)get_store().add_element_user(SEGMENT$0);
            return target;
        }
    }
    
    /**
     * Removes the ith "segment" element
     */
    public void removeSegment(int i)
    {
        synchronized (monitor())
        {
            check_orphaned();
            get_store().remove_element(SEGMENT$0, i);
        }
    }
    
    /**
     * Gets the "id" attribute
     */
    public java.lang.String getId()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
            if (target == null)
            {
                return null;
            }
            return target.getStringValue();
        }
    }
    
    /**
     * Gets (as xml) the "id" attribute
     */
    public org.apache.xmlbeans.XmlID xgetId()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.XmlID target = null;
            target = (org.apache.xmlbeans.XmlID)get_store().find_attribute_user(ID$2);
            return target;
        }
    }
    
    /**
     * Sets the "id" attribute
     */
    public void setId(java.lang.String id)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
            if (target == null)
            {
                target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(ID$2);
            }
            target.setStringValue(id);
        }
    }
    
    /**
     * Sets (as xml) the "id" attribute
     */
    public void xsetId(org.apache.xmlbeans.XmlID id)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.XmlID target = null;
            target = (org.apache.xmlbeans.XmlID)get_store().find_attribute_user(ID$2);
            if (target == null)
            {
                target = (org.apache.xmlbeans.XmlID)get_store().add_attribute_user(ID$2);
            }
            target.set(id);
        }
    }
}
